package com.elancom.rbq.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import com.elancom.framework.entity.AbstractEntity;

/**
 * 树节点
 * 
 * @author elancom
 * 
 */
public abstract class NodeEntity extends AbstractEntity {

	private static final long serialVersionUID = 8745100428850002588L;

	private String pid;

	private String name;

	private NodeEntity parentNode;

	private Set<NodeEntity> children = new HashSet<>();

	private int leaf;

	@Column(name = "PID", insertable = false, updatable = false)
	public String getPid() {
		return pid;
	}

	public void setPid(String pid) {
		this.pid = pid;
	}

	@Column(name = "name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "PID")
	@ManyToOne
	public NodeEntity getParentNode() {
		return parentNode;
	}

	public void setParentNode(NodeEntity parentNode) {
		this.parentNode = parentNode;
	}

	@OneToMany
	@Column(name = "PID")
	public Set<NodeEntity> getChildren() {
		return children;
	}

	public void setChildren(Set<NodeEntity> children) {
		this.children = children;
	}

	@Column(name = "LEAF")
	public int getLeaf() {
		return leaf;
	}

	public void setLeaf(int leaf) {
		this.leaf = leaf;
	}
}
